package com.example.idachuappone.person.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.example.idachuappone.person.entity.Order;
import com.example.idachuappone.person.method.OrderMethod;
import com.example.idachuappone.person.method.OrderMethod.SetOrderList;
import com.example.idachuappone.utils.AppShareData;
import com.example.idachuappone.utils.CheckUtil;
import com.example.idachuappone.utils.Constant;
import com.example.idachuappone.utils.PrefUtil;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;

public class NetReceiver extends BroadcastReceiver {

    class AnonymousClass_1 implements SetOrderList {
        private final /* synthetic */ Context val$context;

        AnonymousClass_1(Context context) {
            this.val$context = context;
        }

        public void onSuccess(List<Order> list, String result) {
            try {
                if (new JSONObject(result).getInt("code") == 401) {
                    PrefUtil.getInstance(this.val$context).setUID(null);
                    PrefUtil.getInstance(this.val$context).setAuth(null);
                    PrefUtil.getInstance(this.val$context).setMa(null);
                    PrefUtil.getInstance(this.val$context).setFimallyLocateCoor(null);
                    PrefUtil.getInstance(this.val$context).setArea(null);
                    PrefUtil.getInstance(this.val$context).setXiaoQu(null);
                    PrefUtil.getInstance(this.val$context).setDoor(null);
                    PrefUtil.getInstance(this.val$context).setName(null);
                    PrefUtil.getInstance(this.val$context).setUserAddressId(null);
                    PrefUtil.getInstance(this.val$context).setPhone(null);
                    AppShareData.isPersonFrag = true;
                    AppShareData.isClearData = true;
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        public void onFail() {
        }
    }

    public void onReceive(Context context, Intent intent) {
        if (CheckUtil.checkNet(context)) {
            isLogin(context);
        }
    }

    private void isLogin(Context context) {
        OrderMethod.getOrderList(context, Constant.PROMPTLY_ALL, new AnonymousClass_1(context));
    }
}
